Fix "Syntax error or access violation: Duplicate key name" If we app…#38143
Fix "Syntax error or access violation: Duplicate key name" If we app…#38143majiddev10 wants to merge 2 commits intomagento:2.4-developfrom
Conversation
|
Hi @Abdul-Majid10. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
…y fulltext index and unique constraint on same column.
swnsma
left a comment
There was a problem hiding this comment.
Hi @Abdul-Majid10,
Thank you for your contribution!
I think it's a really good Pull Request, however there are some points that I am worry about.
Imagine that PR will be merged to Magento codebase and released in new versions.
Anyone who will update to that Magento version and receive these changes would face next steps (during setup:upgrade call):
- All MySQL indexes will be dropped and created again with new name (that may cause issues for merchants with giant DB or those who has some data inconsistency in the DB).
- New index name won't be whitelisted in
etc/db_schema_whitelist.jsonfiles.
So I may suggest 2 options:
- Design and create some logic that would generate index name in a backward compatibility way (e.g. won't generate new name for already existing indexes or generate new name for an index if same name already occupied.
- Update all available
etc/db_schema_whitelist.jsonand add new index name (that would require changes in other repositories). Also, it may require additional approve procedure as changes would introduce BC breaks.
|
Hi @swnsma, The solution involves adding a 4th argument (bool $includePrefix = false) to the getIndexName function. When its value is true, we can concatenate the prefix, similar to this. Note: We can only pass includePrefix true when Key already created for other index. This is just draft to discuss the solution. @swnsma, Looking forward to your response. |
|
Hi @Abdul-Majid10, I would only ask to consider:
Think that I don't like is that right now we generate index name based on the current DB state.
What do you think? |
|
@Abdul-Majid10, Actually, I have even better point to discuss: |


…ly fulltext index and unique constraint on same column.
Description (*)
I have fixed the issue where applying a full-text index and a unique constraint on the same column was causing an error in Magento. The problem has been resolved, and this pull request includes the necessary changes to make this combination work seamlessly.
Error Detail:
Schema File:

Error:

Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)